#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int n, l, r = -1, sum = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
        if(a[i] != 1 && r == -1) {
            l = i, r = i;
        }else if(a[i] != 1) r = i;
    }
    if(r == -1) {
        cout << "1 1\n";
        return;
    }
    int ans = 1;
    vector<int> pos;
    for(int i = l; i <= r; i++) {
        ans = ans * a[i];
        if(ans > 1e9) {
            cout << l + 1 << ' ' << r + 1 << endl;
            return;
        }
        if(a[i] != 1) pos.push_back(i); 
    }
    l++, r++;
    for(int i = 0; i < pos.size(); i++) {
        int l1 = pos[i];
        int cnt = 1;
        int s = 0;
        for(int j = i; j < pos.size(); j++) {
            int r1 = pos[j];
            s += a[r1] - 1;
            cnt *= a[r1];
            int t = sum - s + cnt - (r1 - l1 + 1);
            if(t > ans) {
                ans = t;
                l = l1 + 1, r = r1 + 1;
            }
        }
    }
    cout << l << ' ' << r << endl;
}

signed main() {
   int t;
   cin >> t;
   while(t--) solve(); 
    return 0;
}